package com.tcreditdemo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

public class bbb extends AppCompatActivity {


    private RecyclerView ry;
    private Button bt;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bbb);
        initialize();
    }

    private void initialize() {
        ry = (RecyclerView) findViewById(R.id.ry);
        ry.setLayoutManager(new GridLayoutManager(this,2));
        ry.setAdapter(new Myadapter());
        findViewById(R.id.bt).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onchanger!=null){
                    onchanger.changer();
                }
            }
        });


    }

    public  interface Onchanger{
        void changer();
    }

    public static Onchanger onchanger;
    public static void setOnchangerlistener(Onchanger onchanger){
        bbb.onchanger=onchanger;

    }


    class Myadapter extends RecyclerView.Adapter<Myadapter.Holder>{


        @Override
        public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.ry_bb, parent, false);
            return new Holder(view);
        }

        @Override
        public void onBindViewHolder(Holder holder, int position) {
            //holder.st.setItemHeight();
        }

        @Override
        public int getItemCount() {
            return 4;
        }

        class Holder extends RecyclerView.ViewHolder{
            SettingItemView st;

            public Holder(View itemView) {
                super(itemView);
                 st=itemView.findViewById(R.id.st);
            }
        }
    }
}
